package com.poorstu.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.common.base.web.BaseAction;
import com.poorstu.manager.LoginMeg;

public class PasswordChangeAction extends BaseAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		try{
			DynaActionForm dynaPassword=(DynaActionForm)form;
			int allUserId=(Integer)request.getSession().getAttribute("allUserId");
			String oldPassword=dynaPassword.getString("oldPassword");
			String newPassword=dynaPassword.getString("newPassword");
			LoginMeg loginMeg = (LoginMeg)getBean("loginMeg");
			boolean b=loginMeg.changePwd(allUserId, oldPassword, newPassword);
			
			if(b){
				return mapping.findForward("succ");
			}
			return mapping.findForward("failure");
		}catch(Exception e){
			e.printStackTrace();
			return mapping.findForward("failure");
		}
	}
	
	
	
	

}
